from sqlalchemy import Column, Integer, String, DateTime, Boolean, Index
from sqlalchemy.sql import func
from app.services.db import Base

class StrategyToken(Base):
    __tablename__ = "strategy_tokens"

    id = Column(Integer, primary_key=True, index=True)
    token = Column(String(128), unique=True, index=True, nullable=False)
    tunnel_id = Column(String(100), index=True, nullable=False)
    remark = Column(String(200), nullable=False)
    active = Column(Boolean, default=True, index=True, nullable=False)
    created_at = Column(DateTime(timezone=True), server_default=func.now(), index=True)

    __table_args__ = (
        Index("ix_strategy_tokens_tunnel_active", "tunnel_id", "active", unique=False),
    )